package main

import (
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

//
func main() {
	fmt.Println("hello world")
	fmt.Println(add(1, 2))
	fmt.Println(toJson())
}

//hello world, the web server
func HelloServer(w http.ResponseWriter, req *http.Request) {
	io.WriteString(w, "hello, world!\n")
}

//func main() {
//	fmt.Print()
//}
func add(a, b int) int {
	return a + b
}

func toJson() string {

	var error error
	var str []byte
	data := make(map[string]string)
	data["1"] = "first"
	data["2"] = "second"
	str, error = json.Marshal(data)
	if error != nil {
		return error.Error()
	}
	return string(str)
}
